import 'package:flutter/material.dart';
import 'package:flutter_member/widget/custom_appbar.dart';
import 'package:flutter_member/widget/horizontal_card/card_item.dart';
import 'package:flutter_member/widget/horizontal_card/horizontal_card_pager.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';



class AlbumInfo extends StatefulWidget {
  final List<dynamic>listAlbumInfo;

  const AlbumInfo({Key key, this.listAlbumInfo}) : super(key: key);
  @override
  _AlbumInfoState createState() => _AlbumInfoState();
}

class _AlbumInfoState extends State<AlbumInfo> {
  String bigPicture='https://macauscholar.demo.ourmi.biz/api/files/macauscholar/ab621f7de840aa788221ec5f95d51a97_food.jpeg';
  //  多图预览
  List<CardItem> items = [];
  void album(){
    widget.listAlbumInfo.map((e) =>  items.add(
      ImageCarditem(image:Container(
        height: ScreenUtil().setHeight(60),
        width: ScreenUtil().setWidth(75),
        decoration: BoxDecoration(
            borderRadius: BorderRadius.all(Radius.circular(8)),
//                    color: Colors.teal,
            image: DecorationImage(
                image: NetworkImage(e['url']), fit: BoxFit.fill)),
      )),
    )).toList();
  }
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    album();
  }
  @override
  Widget build(BuildContext context) {
    widget.listAlbumInfo.map((e) => print("----------$e")).toList();

    return CustomAppBar(
        title: '学生相册',
        upperColor: 0xff2D7FC7,
        lowerColor: 0xffE5EEF6,
        hight: 75,
        body: Container(
          height: ScreenUtil().setHeight(667),
          width: ScreenUtil().setWidth(375),
//      color: Colors.amber,
          child: Column(
            children: [
              Expanded(
                child: Stack(
                  children: [
                    Container(
                      alignment: Alignment.bottomRight,
                      margin: EdgeInsets.all(20),
                      decoration: BoxDecoration(
                          borderRadius: BorderRadius.all(Radius.circular(8)),
//                    color: Colors.teal,
                          boxShadow: [
                            BoxShadow(
                                color: Color(0xffebeef2), blurRadius: 5.0, spreadRadius: 2.0),
                            BoxShadow(
                                color: Color(0xffeff1f5), blurRadius: 5.0, spreadRadius: 2.0)
                          ],
                          image: DecorationImage(
                              image:NetworkImage(bigPicture), fit: BoxFit.fill)),
                      child: IconButton(
                        icon: Image.asset('images/download.png'),
                        onPressed: () => print('111'),
                      ),
                    )
                  ],
                ),
              ),
              Container(
                  height: ScreenUtil().setHeight(75),
                  margin: EdgeInsets.only(bottom: 50, top: 100, left: 20, right: 20),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(8))
                  ),
                  child: HorizontalCardPager(
                    onPageChanged: (page) {
                      setState(() {
                        bigPicture = widget.listAlbumInfo[page.floor()]['url'];
                      });
                    },
                    items: items,
                  ))
            ],
          ),
        ));
  }
}
